package com.rcp.steve.mail;

import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

import lotus.domino.NotesThread;
import lotus.domino.Session;
import lotus.domino.*; 

public class MyAgent extends EclipseAgentBase {

private String sendname;
private String servername;
private String filepatch;

public static void main(String[] args){
	MyAgent m = new MyAgent();
    
}
public MyAgent(){
    try {
        InputStream in = this.getClass().getClassLoader().getResourceAsStream(
                "com/rcp/steve/connection/config.properties");
        Properties props = new Properties();
         props.load(in);
         this.sendname=props.getProperty("sendname");
         this.servername=props.getProperty("servername");
         this.filepatch=props.getProperty("filepatch");
         System.out.println(sendname);
         System.out.println(servername);
         System.out.println(filepatch);
    } catch (IOException e) {
        
        e.printStackTrace();
    }
    
}
public void sendMail(String text) {
try {
    Session session = this.getSession();
    System.out.println("Username: " + session.getUserName());
    Database   db=session.getDatabase(servername,filepatch,true);
    Document   domMail=db.createDocument();   
    domMail.appendItemValue("Form","Memo");   
    RichTextItem   body=domMail.createRichTextItem("body"); 

    body.appendText(text);   

    domMail.send(sendname);   
    System.out.println("done");   
    } catch (Exception e) {
        e.printStackTrace();
        }
    }


}